package com.tanhua.admin.task;

import com.tanhua.admin.service.AnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class AnalysisTask {

    @Autowired
    private AnalysisService analysisService;

    /**
     * 定时任务：定时统计tb_log中的数据，保存或更新analysis表中的数据
     */
    @Scheduled(cron = "0/10 * * * * ?") //每隔10秒
    public void analysis(){
/*        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        System.out.println(time);*/
        try {
            analysisService.analysis();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
